package com.tanhua.manager.controller;

import com.tanhua.manager.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/manage")
public class ManageController {

    @Autowired
    private ManageService manageService;

    @GetMapping(value = "/users",name = "分页查询用户")
    public ResponseEntity queryUsers(@RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10")Integer pagesize,
                                     Long id,
                                     String nickname,
                                     String city){

        return manageService.queryUsers(page,pagesize,id,nickname,city);
    }
    @GetMapping(value = "/users/{ID}",name = "查询指定用户数据")
    public ResponseEntity queryUserInfo(@PathVariable("ID")Long userId){
        return manageService.queryUserInfo(userId);
    }

    @GetMapping(value = "/messages",name = "分页查询指定用户的圈子动态")
    public ResponseEntity queryUserMessages(@RequestParam(defaultValue = "1") Integer page,
                                            @RequestParam(defaultValue = "10") Integer pagesize,
                                            @RequestParam(value = "uid",required = false) Long userId,
                                            Integer state) {
        return manageService.queryUserMessages(page, pagesize, userId, state);

    }
@PostMapping(value = "/messages/pass",name = "动态通过")
    public ResponseEntity passUserMessages(@RequestBody List<String>ids,Integer state){
      return   manageService.passUserMessages(ids,state);

}
@PostMapping(value = "/messages/reject",name="动态拒绝")
    public ResponseEntity rejectUserMessages(@RequestBody List<String>ids,Integer state){
        return manageService.rejectUserMessages(ids,state);

    }

    //    分页查询指定用户的小视频
//    请求方式 get
//     请求地址  /manage/videos
//    请求参数 token
//     Query参数  page  pagesize  uid
//      返回类型 PageResult
    @GetMapping(value = "/videos",name = "分页查询指定用户的小视频")
    public ResponseEntity queryUserVideos(@RequestParam(defaultValue = "1") Integer page,
                                          @RequestParam(defaultValue = "10") Integer pagesize,
                                          @RequestParam(value = "uid",required = false) Long userId){
        return manageService.queryUserVideo(page,pagesize,userId);

    }

}
